package com.byq.mm.smartlib.obd.commands.fuel;

import com.byq.mm.smartlib.obd.commands.AbstractObdCommand;
import com.byq.mm.smartlib.obd.commands.utils.ObdUtils;
import com.byq.mm.smartlib.obd.enums.AvailableCommandNames;


/** * This command is intended to determine the vehicle fuel type. */
public class FuelTypeObdCommand extends AbstractObdCommand {
	private int fuelType = 0;

	/** * Default ctor. */
	public FuelTypeObdCommand() {
		super("10 51");
	}

	/** * Copy ctor * * @param other */
	public FuelTypeObdCommand(AbstractObdCommand other) {
		super(other);
	} /*           
	 * * (non-Javadoc) * * @see
	 * eu.lighthouselabs.obd.command.ObdCommand#getFormattedResult()
	 */

	@Override
	public String getFormattedResult() {
		String res = getResult();
		if (!"NODATA".equals(res)) {
			fuelType = buffer.get(2);
			res = getFuelTypeName();
		}
		return res;
	}

	/** * @return Fuel type name. */
	public final String getFuelTypeName() {
		return ObdUtils.getFuelTypeName(fuelType);
	}

	@Override
	public String getName() {
		return AvailableCommandNames.FUEL_TYPE.getValue();
	}

	@Override
	public String getRequestKey() {
		// TODO Auto-generated method stub
		return "10 51";
	}
}